class @ShowProfileView extends CustomView

    initialize: ->
        super
        @setElement("#main")
        @model.bind("change", @render)
        @model.fetch()

    render: ->
        @GetTemplate(SiteMap.Profile.ProfileTemplate, (compiledTemplate) =>
            $(@el).html(compiledTemplate(@model.toJSON()))
        )

    events: 
        "click li.show-profile-rated-books": "showProfileRatedBooks"
        "click button.add-to-friends": "addToFriends"
        "click button.send-message": "sendMessage"
        "click li.show-prifile-friends" : "getFriends"

    showProfileRatedBooks: (e) ->
        e.preventDefault()
        url = SiteMap.Account.ShowProfileRatedBooks + "/" + @model.get("Login")
        @Navigate(url, true)

    addToFriends: (e) ->
        e.preventDefault()
        url = SiteMap.Friends.AddToFriends + "?friend=" + @model.get("Login")
        @Navigate(url,true)

    sendMessage: (e) ->
        e.preventDefault()
        model = new SendMessageModel()
        model.set(
            "SenderId": @model.get("CurrentUserId")
            "RecipientId": @model.get("UserId")
        )
        view = new SendMessageView(model: model)

    getFriends: (e) ->
        e.preventDefault()
        url = SiteMap.Friends.FriendsListing + "?userlogin="+ @model.get("Login")
        @Navigate(url,true)
